<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.10"/>
<title>dev: dev/dev/net/EventLoop.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">dev
   &#160;<span id="projectnumber">0.2</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.10 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('_event_loop_8hpp_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">EventLoop.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/******************************************************************************</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * Name         : EventLoop.hpp</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * Author       : 671643387</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * Date         : 2015年9月6日</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * Description  : 事件循环，占用线程资源，负责网络IO的派发和处理发送到其的消息</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> *****************************************************************************/</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#ifndef NET_EVENTLOOP_HPP_</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#define NET_EVENTLOOP_HPP_</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#include &lt;boost/noncopyable.hpp&gt;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;boost/function.hpp&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;dev/base/Mutex.hpp&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;dev/base/LockGuard.hpp&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#include &lt;dev/base/LockedQueue.hpp&gt;</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor">#include &lt;dev/base/TimeUtil.hpp&gt;</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="preprocessor">#include &lt;dev/net/Reactor.hpp&gt;</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacedev.html">dev</a></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;{</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;    <span class="keyword">namespace </span>net</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    {</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;        <span class="keyword">class </span>TcpWorker;</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;        <span class="keyword">class </span>TcpServer;</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;</div>
<div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="classdev_1_1net_1_1_event_loop.html">   29</a></span>&#160;        <span class="keyword">class </span><a class="code" href="classdev_1_1net_1_1_event_loop.html">EventLoop</a> : <span class="keyword">public</span> boost::noncopyable</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        {</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;            <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classdev_1_1net_1_1_tcp_worker.html">TcpWorker</a>;</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;            <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classdev_1_1net_1_1_tcp_server.html">TcpServer</a>;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;            <span class="keyword">typedef</span> boost::function&lt;void(Socket*)&gt; PassSocketPointerCB;</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;            <span class="keyword">enum</span> Status</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;            {</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;                READY,      <span class="comment">// 准备就绪</span></div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;                RUNNING,    <span class="comment">// 执行中</span></div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;                EXITING,    <span class="comment">// 退出中</span></div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;                EXIT        <span class="comment">// 已退出</span></div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;            };</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;            <a class="code" href="classdev_1_1net_1_1_event_loop.html">EventLoop</a>();</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;            <a class="code" href="classdev_1_1net_1_1_event_loop.html">EventLoop</a>(<a class="code" href="classdev_1_1net_1_1_reactor.html">Reactor</a>* rector);</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;            ~<a class="code" href="classdev_1_1net_1_1_event_loop.html">EventLoop</a>();</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;            <span class="keywordtype">int</span> <a class="code" href="classdev_1_1net_1_1_event_loop.html#aabaaf8e05a0862f12d5ab65fcf772633">run</a>(<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classdev_1_1net_1_1_event_loop.html#a2115323b7b33ddab22e986c64c2741a8">stop</a>(<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classdev_1_1net_1_1_event_loop.html#a065de9a81bafe581317bd49536afbf6a">queueEvent</a>(boost::function&lt;<span class="keywordtype">void</span>(<span class="keywordtype">void</span>)&gt; handler);</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classdev_1_1net_1_1_event_loop.html#ac6a263ce319c3be4036cc621d3a4e254">addSocket</a>(<a class="code" href="classdev_1_1net_1_1_socket.html">Socket</a>* sock, Reactor::EventType events, <a class="code" href="classdev_1_1net_1_1_socket_event_handler.html">SocketEventHandler</a>* handler);</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classdev_1_1net_1_1_event_loop.html#ab198f9ccb0bdd9722e300970ba522371">removeSocket</a>(<a class="code" href="classdev_1_1net_1_1_socket.html">Socket</a>* sock);</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00088"></a><span class="lineno"><a class="line" href="classdev_1_1net_1_1_event_loop.html#afeeb886d08c61f513723581a4462c7a7">   88</a></span>&#160;            Status <a class="code" href="classdev_1_1net_1_1_event_loop.html#afeeb886d08c61f513723581a4462c7a7">getStatus</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> status_; }</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;</div>
<div class="line"><a name="l00094"></a><span class="lineno"><a class="line" href="classdev_1_1net_1_1_event_loop.html#a3cc34cdad07de13a6612fdc7dd660cbf">   94</a></span>&#160;            ReactorPtr&amp; <a class="code" href="classdev_1_1net_1_1_event_loop.html#a3cc34cdad07de13a6612fdc7dd660cbf">getReactor</a>(<span class="keywordtype">void</span>) { <span class="keywordflow">return</span> reactor_; }</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;</div>
<div class="line"><a name="l00100"></a><span class="lineno"><a class="line" href="classdev_1_1net_1_1_event_loop.html#a5c0413d7e832d1da05e0a19d2c0b3d59">  100</a></span>&#160;            base::mtime_t <a class="code" href="classdev_1_1net_1_1_event_loop.html#a5c0413d7e832d1da05e0a19d2c0b3d59">getFrameTime</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> frameTime_; }</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;</div>
<div class="line"><a name="l00106"></a><span class="lineno"><a class="line" href="classdev_1_1net_1_1_event_loop.html#a0d109507f05fa7e25e25c8786c765daf">  106</a></span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classdev_1_1net_1_1_event_loop.html#a0d109507f05fa7e25e25c8786c765daf">setFrameTime</a>(base::mtime_t time) { frameTime_ = time; }</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;</div>
<div class="line"><a name="l00112"></a><span class="lineno"><a class="line" href="classdev_1_1net_1_1_event_loop.html#a8e1fef09fb4c03dd0ee629e700aa6e67">  112</a></span>&#160;            <span class="keywordtype">int</span> <a class="code" href="classdev_1_1net_1_1_event_loop.html#a8e1fef09fb4c03dd0ee629e700aa6e67">getId</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> id_; }</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;</div>
<div class="line"><a name="l00118"></a><span class="lineno"><a class="line" href="classdev_1_1net_1_1_event_loop.html#a6a7dc03f144ed38d10b40547922501a3">  118</a></span>&#160;            <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <a class="code" href="classdev_1_1net_1_1_event_loop.html#a6a7dc03f144ed38d10b40547922501a3">getLoopCounter</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> loopCounter_; }</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;</div>
<div class="line"><a name="l00124"></a><span class="lineno"><a class="line" href="classdev_1_1net_1_1_event_loop.html#ac5e0b8420fd73e47c2b806135893abb7">  124</a></span>&#160;            base::mtime_t <a class="code" href="classdev_1_1net_1_1_event_loop.html#ac5e0b8420fd73e47c2b806135893abb7">getFrameSystemTime</a>(<span class="keywordtype">void</span>)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> frameSysTime_; }</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;</div>
<div class="line"><a name="l00130"></a><span class="lineno"><a class="line" href="classdev_1_1net_1_1_event_loop.html#aa12ef12c8efa905621d3f9d834cd1f19">  130</a></span>&#160;            <span class="keywordtype">void</span> <a class="code" href="classdev_1_1net_1_1_event_loop.html#aa12ef12c8efa905621d3f9d834cd1f19">setRemoveSocketCallback</a>(PassSocketPointerCB callback) { removeSocketCB_ = callback; }</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;            <span class="keywordtype">void</span> setStatus(Status status) { status_ = status; }</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;            <span class="keywordtype">void</span> doAddSocket(Socket* sock, Reactor::EventType events, SocketEventHandler* handler);</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;            <span class="keywordtype">void</span> doRemoveSocket(Socket* sock);</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;            <span class="keywordtype">int</span> id_;                                                    <span class="comment">// 标志ID</span></div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;            Status status_;                                             <span class="comment">// 状态</span></div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;            base::mtime_t frameTime_;                                   <span class="comment">// 帧时间(毫秒)，默认每秒50帧</span></div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;            base::mtime_t frameSysTime_;                                <span class="comment">// 每帧系统执行的时间</span></div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;            ReactorPtr reactor_;                                        <span class="comment">// 网络消息派发器</span></div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;            <span class="keyword">volatile</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> loopCounter_;                   <span class="comment">// 循环次数</span></div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;            PassSocketPointerCB removeSocketCB_;                        <span class="comment">// 套接字移除回调</span></div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;            <span class="keyword">struct </span>_Event</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;            {</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;                base::mtime_t time;                                    <span class="comment">// 事件插入时间</span></div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;                boost::function&lt;void(void)&gt; handler;                   <span class="comment">// 事件处理器</span></div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;            };</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;            base::LockedQueue&lt;struct _Event, base::Mutex&gt;  events_;     <span class="comment">// 事件队列</span></div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;            <span class="comment">/* 负责从事件队列提取事件时过滤事件 */</span></div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;            <span class="keyword">class </span>Checker</div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;            {</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;            <span class="keyword">public</span>:</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;                Checker() : time_(base::TimeUtil::fromStartup()){}</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;                <span class="keywordtype">bool</span> process(<span class="keyword">struct</span> _Event&amp; event)</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;                {</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;                    <span class="keywordflow">return</span> (event.time &lt;= time_);</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;                }</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;            <span class="keyword">private</span>:</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;                base::mtime_t time_;</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;            };</div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;        };</div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;    }</div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;}</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* NET_EVENTLOOP_HPP_ */</span><span class="preprocessor"></span></div>
<div class="ttc" id="namespacedev_html"><div class="ttname"><a href="namespacedev.html">dev</a></div><div class="ttdef"><b>Definition:</b> Atomic.hpp:18</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_a2115323b7b33ddab22e986c64c2741a8"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#a2115323b7b33ddab22e986c64c2741a8">dev::net::EventLoop::stop</a></div><div class="ttdeci">void stop(void)</div><div class="ttdoc">停止事件循环 </div><div class="ttdef"><b>Definition:</b> EventLoop.cpp:93</div></div>
<div class="ttc" id="classdev_1_1net_1_1_tcp_server_html"><div class="ttname"><a href="classdev_1_1net_1_1_tcp_server.html">dev::net::TcpServer</a></div><div class="ttdef"><b>Definition:</b> TcpServer.hpp:31</div></div>
<div class="ttc" id="classdev_1_1net_1_1_reactor_html"><div class="ttname"><a href="classdev_1_1net_1_1_reactor.html">dev::net::Reactor</a></div><div class="ttdoc">网络反应器 </div><div class="ttdef"><b>Definition:</b> Reactor.hpp:23</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_a8e1fef09fb4c03dd0ee629e700aa6e67"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#a8e1fef09fb4c03dd0ee629e700aa6e67">dev::net::EventLoop::getId</a></div><div class="ttdeci">int getId(void) const </div><div class="ttdoc">获取事件循环的ID </div><div class="ttdef"><b>Definition:</b> EventLoop.hpp:112</div></div>
<div class="ttc" id="classdev_1_1net_1_1_tcp_worker_html"><div class="ttname"><a href="classdev_1_1net_1_1_tcp_worker.html">dev::net::TcpWorker</a></div><div class="ttdef"><b>Definition:</b> TcpWorker.hpp:31</div></div>
<div class="ttc" id="classdev_1_1net_1_1_socket_event_handler_html"><div class="ttname"><a href="classdev_1_1net_1_1_socket_event_handler.html">dev::net::SocketEventHandler</a></div><div class="ttdoc">套接字事件处理器 </div><div class="ttdef"><b>Definition:</b> SocketEventHandler.hpp:21</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_a6a7dc03f144ed38d10b40547922501a3"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#a6a7dc03f144ed38d10b40547922501a3">dev::net::EventLoop::getLoopCounter</a></div><div class="ttdeci">unsigned long long getLoopCounter(void) const </div><div class="ttdoc">获取事件循环已经循环的次数 </div><div class="ttdef"><b>Definition:</b> EventLoop.hpp:118</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_a0d109507f05fa7e25e25c8786c765daf"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#a0d109507f05fa7e25e25c8786c765daf">dev::net::EventLoop::setFrameTime</a></div><div class="ttdeci">void setFrameTime(base::mtime_t time)</div><div class="ttdoc">设置事件循环的帧时间 </div><div class="ttdef"><b>Definition:</b> EventLoop.hpp:106</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_afeeb886d08c61f513723581a4462c7a7"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#afeeb886d08c61f513723581a4462c7a7">dev::net::EventLoop::getStatus</a></div><div class="ttdeci">Status getStatus(void) const </div><div class="ttdoc">获取事件循环状态 </div><div class="ttdef"><b>Definition:</b> EventLoop.hpp:88</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html">dev::net::EventLoop</a></div><div class="ttdoc">事件循环 </div><div class="ttdef"><b>Definition:</b> EventLoop.hpp:29</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_a065de9a81bafe581317bd49536afbf6a"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#a065de9a81bafe581317bd49536afbf6a">dev::net::EventLoop::queueEvent</a></div><div class="ttdeci">void queueEvent(boost::function&lt; void(void)&gt; handler)</div><div class="ttdoc">在事件循环执行这个函数 </div><div class="ttdef"><b>Definition:</b> EventLoop.cpp:100</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_aa12ef12c8efa905621d3f9d834cd1f19"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#aa12ef12c8efa905621d3f9d834cd1f19">dev::net::EventLoop::setRemoveSocketCallback</a></div><div class="ttdeci">void setRemoveSocketCallback(PassSocketPointerCB callback)</div><div class="ttdoc">设置事件循环套接字移除回调函数，当完成移除这个套接字时会调用 </div><div class="ttdef"><b>Definition:</b> EventLoop.hpp:130</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_ac6a263ce319c3be4036cc621d3a4e254"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#ac6a263ce319c3be4036cc621d3a4e254">dev::net::EventLoop::addSocket</a></div><div class="ttdeci">void addSocket(Socket *sock, Reactor::EventType events, SocketEventHandler *handler)</div><div class="ttdoc">绑定套接字到事件循环，事件循环会负责检查这个套接字上的事件并派发 </div><div class="ttdef"><b>Definition:</b> EventLoop.cpp:106</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_ab198f9ccb0bdd9722e300970ba522371"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#ab198f9ccb0bdd9722e300970ba522371">dev::net::EventLoop::removeSocket</a></div><div class="ttdeci">void removeSocket(Socket *sock)</div><div class="ttdoc">从事件循环移除这个套接字 </div><div class="ttdef"><b>Definition:</b> EventLoop.cpp:112</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_a3cc34cdad07de13a6612fdc7dd660cbf"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#a3cc34cdad07de13a6612fdc7dd660cbf">dev::net::EventLoop::getReactor</a></div><div class="ttdeci">ReactorPtr &amp; getReactor(void)</div><div class="ttdoc">获取事件循环的网络反应器 </div><div class="ttdef"><b>Definition:</b> EventLoop.hpp:94</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_ac5e0b8420fd73e47c2b806135893abb7"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#ac5e0b8420fd73e47c2b806135893abb7">dev::net::EventLoop::getFrameSystemTime</a></div><div class="ttdeci">base::mtime_t getFrameSystemTime(void) const </div><div class="ttdoc">获取事件循环当前执行一帧消耗的时间 </div><div class="ttdef"><b>Definition:</b> EventLoop.hpp:124</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_a5c0413d7e832d1da05e0a19d2c0b3d59"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#a5c0413d7e832d1da05e0a19d2c0b3d59">dev::net::EventLoop::getFrameTime</a></div><div class="ttdeci">base::mtime_t getFrameTime(void) const </div><div class="ttdoc">获取事件循环的帧时间 </div><div class="ttdef"><b>Definition:</b> EventLoop.hpp:100</div></div>
<div class="ttc" id="classdev_1_1net_1_1_event_loop_html_aabaaf8e05a0862f12d5ab65fcf772633"><div class="ttname"><a href="classdev_1_1net_1_1_event_loop.html#aabaaf8e05a0862f12d5ab65fcf772633">dev::net::EventLoop::run</a></div><div class="ttdeci">int run(void)</div><div class="ttdoc">执行事件循环 </div><div class="ttdef"><b>Definition:</b> EventLoop.cpp:54</div></div>
<div class="ttc" id="classdev_1_1net_1_1_socket_html"><div class="ttname"><a href="classdev_1_1net_1_1_socket.html">dev::net::Socket</a></div><div class="ttdoc">套接字 </div><div class="ttdef"><b>Definition:</b> Socket.hpp:23</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_5fc0168d11760b9445bd29fa15d9290f.html">dev</a></li><li class="navelem"><a class="el" href="dir_1ca75188a6074d2843e8fd5d982c3101.html">dev</a></li><li class="navelem"><a class="el" href="dir_cea828ca1984caf90af75ecf8a99968a.html">net</a></li><li class="navelem"><b>EventLoop.hpp</b></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.10 </li>
  </ul>
</div>
</body>
</html>
